package com.evil.Servlet;

import com.evil.Utils.Log;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;

/********************************************
 * 工程名：Web
 * 包名：${PACKAGE_NAME}
 * 时间：16-9-17 下午8:05
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：
 ********************************************/
public class DownloadServlet extends BaseServlet
{
    @Override
    public void doPost() throws IOException
    {
        Log.println("进入");
        String path = request.getSession().getServletContext().getRealPath("/");//获取路径
        File rootDir = new File(path + "/update");
        String[] fileList = rootDir.list();
        String filename = null;
        if (fileList != null)
        {
            filename = fileList[fileList.length - 1];
        }

        response.sendRedirect("./update/" + filename);
    }

    @Override
    public void doGet() throws IOException
    {
        this.doPost();
    }
}
